class BuildFilter
  
  def creates(filter)
      
      filType = filter[:filterType]
      filProp = filter[:filter]
      
      filObj = String.new
      
      if filType == 'Simple' and filProp.length == 3 then
        filterDef = SimpleFilterPart.new(filProp[0],filProp[1],filProp[2])
      else

        complexFilter = []

        filProp.each do |f|

          if f.class == Array and f.length == 3 then
            complexFilter.push(SimpleFilterPart.new(f[0],f[1],f[2]))
          else
            complexFilter.push(f.upcase)
          end

        end

        filterDef = ComplexFilterPart.new(*complexFilter)
      end
      
  end

end

class BuildRetrieve

  def creates(props,filter)
    
    obj = props[:object]
    props = props[:props]
    
    if filter != nil then
      filterObj = BuildFilter.new()
      filter = filterObj.creates(filter)
      retObj = RetrieveRequest.new(nil,obj,props,filter)
    else
      retObj = RetrieveRequest.new(nil,obj,props)
    end
    
    resp = $driver.retrieve(RetrieveRequestMsg.new(retObj))

  end
  
end

class BuildDescribe
  
  def initialize(props)
    @@object = props[:object]
  end

  def creates
    descObj = ArrayOfObjectDefinitionRequest.new([ObjectDefinitionRequest.new(nil,@@object)])
    resp = $driver.describe(DefinitionRequestMsg.new(descObj))
  end

end